//
//  CommentCellTableViewCell.m
//  代号：47
//
//  Created by 杨佩璋 on 15/7/3.
//  Copyright (c) 2015年 杨佩璋. All rights reserved.
//

#import "CommentCell.h"
#import <UIImageView+WebCache.h>


@implementation CommentCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        _picture = [[UIImageView alloc] init];
        _picture.contentMode = UIViewContentModeScaleAspectFill;
        _picture.clipsToBounds = YES;
        _titleLabel = [[UILabel alloc] init];
        _commentLabel = [[UILabel alloc] init];
        CGFloat titleWidth = kScreen_width - 150 -10;
        CGFloat h = 130 *141.0/188;
        _picture.frame = CGRectMake(10, 10, 130, h);
        _titleLabel.frame = CGRectMake(150, 15, titleWidth, 60);
        _titleLabel.numberOfLines = 0;
        _titleLabel.textAlignment = NSTextAlignmentLeft;
        _commentLabel.frame = CGRectMake(130, 90, titleWidth, 20);
        _titleLabel.font = [UIFont boldSystemFontOfSize:14];
        _titleLabel.textColor = [UIColor orangeColor];
        _commentLabel.font = [UIFont systemFontOfSize:10];
        _commentLabel.textColor = [UIColor lightGrayColor];
        _commentLabel.textAlignment = NSTextAlignmentRight;
        [self.contentView addSubview:_titleLabel];
        [self.contentView addSubview:_picture];
        [self.contentView addSubview:_commentLabel];
        [_commentLabel release];
        [_titleLabel release];
        [_picture release];
        
    }
    return  self;
}

- (void)setModel:(CommentModel *)model
{
    if (_model != model) {
        [_model release];
        _model = [model retain];
    }
    NSString *str = model.coverImage[@"url"];
    [_picture sd_setImageWithURL:[NSURL URLWithString:str]];
    _titleLabel.text = model.title;
    NSString *count = [NSString stringWithFormat:@"%@",model.commentCount];
    _commentLabel.text = [NSString stringWithFormat:@"评论数%@",count];
    
}

-(void)dealloc{
    
    [_model release];
    [super dealloc];
}


@end
